package work_Experiment_3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-11-03
 * Time: 17:13
 */
import java.util.InputMismatchException;
import java.util.Scanner;

// 自定义异常类
class SpecialInputException extends Exception {
    public SpecialInputException(String message) {
        super(message);
    }
}

public class DivisionCalculator {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        try {
            System.out.print("请输入一个整数: ");
            int numerator = scanner.nextInt();

            // 检查是否有特定的输入，比如13
            if (numerator == 13 || numerator == 4) {
                throw new SpecialInputException("输入的数值为13或4，这是不被允许！");
            }

            System.out.println("您输入的数为:" + numerator);

        } catch (SpecialInputException e) {
            System.err.println("自定义异常: " + e.getMessage());
        } catch (InputMismatchException e) {
            // 捕获输入类型不匹配异常
            System.err.println("异常: 输入的不是有效的整数！");
        }
    }
}